package com.rihel.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtil {
    private static final String driver = "com.mysql.jdbc.Driver";
    private static final String url = "jdbc:mysql://localhost:3306/logindemo?useSSH=false";
    private static final String uname = "root";
    private static final String pwd ="1234";
    private static Connection connection;
    static {
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static Connection getconn() throws SQLException {
        if(connection==null){
            connection= DriverManager.getConnection(url,uname,pwd);

        }
        return connection;
    }

    public static void main(String[] args) throws SQLException {
        DBUtil.getconn();
    }
}
